<div class="filter-bar">
	<form action="__CONTROLLER__/index" method="post" >
		<div class="view">
			<div class="row clearfix">
				<div class="col-md-4 column row ui-sortable">
				    <label class="col-sm-4 control-label" style="margin-top: 8px;">订单编号</label>
				    <div class="col-sm-8">
				   		<input type="text" name="orderId" class="form-control" value="{$params.orderId}"/>
				    </div>
				</div>	
				<div class="col-md-4 column row ui-sortable">
				    <label class="col-sm-3 control-label" style="margin-top: 8px;">订单类型</label>
				    <div class="col-sm-9">
					      <select class="form-control" style="float: left;margin-right: 10px;"  name="type">
			              {$orderTypesOptions}
			              </select>
				    </div>
				</div>
			</div>
			<div class="row clearfix" style="margin-top:10px;">
				<div class="col-md-4 column row ui-sortable">
				    <label class="col-sm-4 control-label" style="margin-top: 8px;">OpenId</label>
				    <div class="col-sm-8">
				   		<input type="text" name="openId" class="form-control" value="{$params.openId}"/>
				    </div>
				</div>
				<div class="col-md-4 column row ui-sortable">
				    <label class="col-sm-3 control-label" style="margin-top: 8px;">收货人</label>
				    <div class="col-sm-9">
				   		<input type="text" name="consignee" class="form-control" value="{$params.consignee}"/>
				    </div>
				</div>	
				<div class="col-md-4 column row ui-sortable">
				    <label class="col-sm-3 control-label" style="margin-top: 8px;">收货人电话</label>
				    <div class="col-sm-9">
				   		<input type="text" name="tel" class="form-control" value="{$params.tel}"/>
				    </div>
				</div>	
			</div>
			<div class="row clearfix" style="margin-top:10px;">
				<div class="column row ui-sortable">
				    <div style="float:right;margin-right:120px">
			              <input type="submit"  class="btn btn-primary" value="搜索">
						  <div class='btn-group'>
							<input id="btnExportExcel" data-url="{:U(CONTROLLER_NAME.'/exportOrderXLS')}" data-details-url="{:U(CONTROLLER_NAME.'/exportXLS')}" type="button" class="btn btn-info" value="导出Excel"/>
							<a class='btn btn-info dropdown-toggle' data-toggle='dropdown' href='javascript:;'><span class='caret'></span></a>
							<ul class='dropdown-menu' role="menu">
								<li style="padding-left: 12px;">
								   <div class="checkbox">
								      <label><input id="btn-xls-details" name="{$params.exportDetail}" type="checkbox" {$params['exportDetail']?'checked="checked"':''}>导出详细</label>
								  </div>
								</li>
							</ul>
						  </div>
				    </div>
				</div>	
			</div>
		</div>
	</form>
</div>
<hr/>
<table class="table table-hover">
 <thead>
  <tr>
   <th>ID</th>
   <th>订单编号</th>
   <th>微信用户/OpenId</th>
   <th>收货人</th>
   <th>收货人电话</th>
   <th>下单时间</th>
   <th>支付时间</th>
   <th>订单状态</th>
   <th>操作</th>
  </tr>
 </thead>
 <tbody>
  <volist name="productOrderLists" id="vo">
   <tr>
    <td>{$vo.id}</td>
    <td>{$vo.order_id}</td>
    <td>{$vo.nickname}<br/>{$vo.openId}<br/></td>
    <td>{$vo.consignee}</td>
    <td>{$vo.tel}</td>
    <td>{$vo.create_time|date="Y-m-d H:i:s", ###}</td>
    <td>{$vo['pay_time']?date('Y-m-d H:i:s', $vo['pay_time']):'--'}</td>
    <td class="order-show-status">{$vo.orderStatusName}</td>
    <td>
      <if condition="in_array('deliver', $vo['operates'])"><a class="btn btn-primary btn-xs" href="__CONTROLLER__/detials/id/{$vo.id}">发货</a></if>
      <if condition="in_array('check_comment', $vo['operates'])"><a class="btn btn-primary btn-xs" href="__CONTROLLER__/comment/id/{$vo.id}">审核评价</a></if>
      <if condition="in_array('act_for_sign', $vo['operates'])"><a order-id="{$vo.id}" class="btn btn-primary btn-xs act-for-sign" href="javascript:void(0);">代理签收</a></if>
      <if condition="in_array('cancel', $vo['operates'])"><a order-id="{$vo.id}" class="btn btn-primary btn-xs cancel" href="javascript:void(0);">取消订单</a></if>
      <a class="btn btn-info btn-xs" href="__CONTROLLER__/detials/id/{$vo.id}">订单详情</a>
      <a class="btn btn-danger btn-xs actionds" data-action-id="{$vo.id}" data-action-txt="移除中……" data-action-url="__CONTROLLER__/remove">移除</a>
    </td>
   </tr>
  </volist>
 </tbody>
</table>
<div class="pagination">{$pagination}</div>

<script type="text/javascript">
$(function() {
	$(".cancel").click(function() {
		if ( confirm("确定取消订单吗？") ) {
			var scope = this;
			$(this).attr('disabled', "disabled");
			$.post('__CONTROLLER__/cancelOrder', {id:$(this).attr("order-id")}, function( data ) {
				if ( data.error == 0 ) {
					$(scope).parents("tr:eq(0)").find(".order-show-status").html("已取消");
					$(scope).remove();
					alert('已取消');
				} else {
					$(scope).removeAttr('disabled');
				}
			});
		}
	});
	
	$(".act-for-sign").click(function() {
		if ( confirm("确定把订单设置为已收货吗？") ) {
			var scope = this;
			$(this).attr('disabled', "disabled");
			$.post('__CONTROLLER__/actForSign', {id:$(this).attr("order-id")}, function( data ) {
				if ( data.error == 0 ) {
					$(scope).parents("tr:eq(0)").find(".order-show-status").html("已收货");
					$(scope).remove();
					alert('已设置为已收货');
				} else {
					$(scope).removeAttr('disabled');
					alert(data['msg']);
				}
			});
		}
	});
	
    $("#btnExportExcel").click(function() {
    	if ( $("#btn-xls-details").is(":checked") ) {
    		window.location.href = $(this).attr('data-details-url')+"?"+$('form').serialize();
    	} else {
    		window.location.href = $(this).attr('data-url')+"?"+$('form').serialize();
    	}
    });
});
</script>